﻿using MediatR;
using S.Produce.Domains;
using S.Produce.Infrastructure;
using S.Produce.Read.Api.Application.Commands.WeaningCommands;

namespace S.Produce.Read.Api.Application.CommandHandlers.WeaningCommandHandlers
{
    /// <summary>
    /// 回填种母断奶信息
    /// </summary>
    public class WeaningBackfillCommandHandler : IRequestHandler<WeaningBackfillCommand, Weanings>
    {
        private readonly IRepository<Weanings> _weaningsRepository;

        /// <summary>
        /// 构造方式注入
        /// </summary>
        /// <param name="weaningsRepository"></param>
        public WeaningBackfillCommandHandler(IRepository<Weanings> weaningsRepository)
        {
            _weaningsRepository = weaningsRepository;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<Weanings> Handle(WeaningBackfillCommand request, CancellationToken cancellationToken)
        {
            var weaningInfo = await _weaningsRepository.GetAsync(request.Id);
            return weaningInfo;
        }
    }
}
